package apralms

class Product {
	String code
	String name
	String type
	
	String class1
	String class2
	String class3
	String class4
	String class5
	String class6
	String class7
	String class8
	String class9
	String class10
	
	float k2 = 0
	float ke = 0
	
	String classParas = ''
	
	Boolean finished
	Boolean profession
	
	Date dateCreated
	Date lastUpdated

    static constraints = {
		code blank:false, maxSize:10, unique:true
		name blank:false, maxSize:50, unique:true
		type blank:false
		
		finished nullable: true
		profession nullable: true
		
		project()
		system()
		
		indexes()
		
		class1 blank: false, inList:["0","1","2"]
		class2 blank: false, inList:["0","1","2","3"]
		class3 blank: false, inList:["0","1","2","3"]
		class4 blank: false, inList:["0","1","2","3"]
		class5 blank: false, inList:["0","1","2"]
		class6 blank: false, inList:["0","1","2","3"]
		class7 blank: false, inList:["0","1","2"]
		class8 blank: false, inList:["0","1","2"]
		class9 blank: false, inList:["0","1","2"]
		class10 blank: false, inList:["0","1","2"]
		
		k2 min:0f, max:10f 
		ke min:0f, max:10f
    }
	
	static belongsTo = [project:Project, system:System]
	static hasMany = [indexes:ProductIndex, facts:ProductFact]
	
	def beforeInsert = {

	}
	
	def beforeUpdate = {

	}
	
	String toString(){
		"${name}[${code}]"
	}
}
